//
//  OrderCell.m
//  Zhiche-Carriage
//
//  Created by 王亚陆 on 16/11/1.
//  Copyright © 2016年 LeeBruce. All rights reserved.
//

#import "OrderCell.h"
#import <Masonry.h>

@implementation OrderCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        
//        @property (nonatomic,strong) UILabel * timelabel;
//        @property (nonatomic,strong) UILabel * starlabel;
//        @property (nonatomic,strong) UILabel * endlabel;
//        @property (nonatomic,strong) UILabel * statelabel;
//        @property (nonatomic,strong) UILabel * pricelabel;
//        

        
        _timelabel = [self createUIlabel:@"今天10：30" andFont:FontOfSize14 andColor:BlackColor];
        _starlabel = [self createUIlabel:@"起 江西-萍乡" andFont:FontOfSize12 andColor:BlackColor];
        _endlabel = [self createUIlabel:@"目 福建-厦门" andFont:FontOfSize12 andColor:BlackColor];
        _statelabel = [self createUIlabel:@"派单中 待接单" andFont:FontOfSize14 andColor:RedColor];
        _pricelabel = [self createUIlabel:@"￥240.00" andFont:FontOfSize14 andColor:RedColor];

        [self.contentView addSubview:_timelabel];
        [self.contentView addSubview:_starlabel];
        [self.contentView addSubview:_endlabel];
        [self.contentView addSubview:_statelabel];
        [self.contentView addSubview:_pricelabel];

        [_timelabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).with.offset(14*kWidth);
            make.top.mas_equalTo(self.contentView.mas_top).with.offset(10*kHeight);
        }];

        [_starlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).with.offset(14*kWidth);
            make.top.mas_equalTo(_timelabel.mas_bottom).with.offset(10*kHeight);
        }];

        [_endlabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.contentView.mas_left).with.offset(14*kWidth);
            make.top.mas_equalTo(_starlabel.mas_bottom).with.offset(8*kHeight);
        }];

        [_statelabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).with.offset(-14*kWidth);
            make.centerY.mas_equalTo(_timelabel.mas_centerY);
        }];

        [_pricelabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.contentView.mas_right).with.offset(-14*kWidth);
            make.top.mas_equalTo(_starlabel.mas_bottom).with.offset(10*kHeight);
        }];

    
    
    
    }
    return self;
}
-(UILabel*)createUIlabel:(NSString *)title andFont:(CGFloat)font andColor:(UIColor*)color {
    UILabel * label =[[UILabel alloc]init];
    label.text = title;
    label.textColor = color;
    UIFont *fnt = [UIFont fontWithName:@"HelveticaNeue" size:font];CGSize size = [label.text sizeWithAttributes:[NSDictionary dictionaryWithObjectsAndKeys:fnt,NSFontAttributeName, nil]];
    CGFloat nameH = size.height;
    CGFloat nameW = size.width;
    label.textAlignment = NSTextAlignmentCenter;
    label.frame =CGRectMake(0, 0, nameW, nameH);
    label.font = Font(font);
    return label;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
